﻿
namespace CMS.Class
{
    public class CEditorParser: CHTMLParser
    {
        public CEditorParser(string content) : base(content) { }

        public string GetTitle()
        {
            return base.ParseString("(<p.*?class=\"ptitle\".*?>(.*?)</p>|<div.*?class=\"ptitle\".*?>(.*?)</div>|<span.*?class=\"ptitle\".*?>(.*?)</span>|<font.*?class=\"ptitle\".*?>(.*?)</font>)");
        }

        public string GetHead()
        {
            return base.ParseString("(<p.*?class=\"phead\".*?>(.*?)</p>|<div.*?class=\"phead\".*?>(.*?)</div>|<span.*?class=\"phead\".*?>(.*?)</span>|<font.*?class=\"phead\".*?>(.*?)</font>)");
        }
        public string GetAuthor()
        {
            return base.ParseString("(<p.*?class=\"pauthor\".*?>(.*?)</p>|<div.*?class=\"pauthor\".*?>(.*?)</div>|<span.*?class=\"pauthor\".*?>(.*?)</span>|<font.*?class=\"pauthor\".*?>(.*?)</font>)");
        }
        public string GetSource()
        {
            return base.ParseString("(<p.*?class=\"psource\".*?>(.*?)</p>|<div.*?class=\"psource\".*?>(.*?)</div>|<span.*?class=\"psource\".*?>(.*?)</span>|<font.*?class=\"psource\".*?>(.*?)</font>)");
        }

        /// <summary>
        /// namlb@vietstock.vn - 2011-07-01
        /// </summary>
        /// <returns>string</returns>
        public string getLocation()
        {
            return base.ParseString("(<p.*?class=\"plocation\".*?>(.*?)</p>|<div.*?class=\"plocation\".*?>(.*?)</div>|<span.*?class=\"plocation\".*?>(.*?)</span>|<font.*?class=\"plocation\".*?>(.*?)</font>)");
        }
        /// <summary>
        /// namlb@vietstock.vn - 2011-07-01
        /// </summary>
        /// <returns>string</returns>
        public string getProjectScale()
        {
            return base.ParseString("(<p.*?class=\"pprojectscale\".*?>(.*?)</p>|<div.*?class=\"pprojectscale\".*?>(.*?)</div>|<span.*?class=\"pprojectscale\".*?>(.*?)</span>|<font.*?class=\"pprojectscale\".*?>(.*?)</font>)");
        }

        public string GetContent()
        {
            return this._Content;
            //return base.Replace("<img src='(http|https)://.*?(/.*?)'", "<img src='/");
        }

        public string GetContentWithoutTitle()
        {
            return System.Text.RegularExpressions.Regex.Replace(this._Content, "(<p.*?class=\"pTitle\".*?[^>]*>.*</p>)|(<span.*?class=\"pTitle\".*?[^>](.*)</span>)|(<font.*?class=\"pTitle\".*?[^>](.*)</font>)", "");
        }
    }
}